import Opt from '@/components/dt/info/Opt.js'
import ruleOpt from '@/biz/option/rule.js'

class ConfigOpt extends Opt {
  constructor(info) {
    super(info)
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      {
        title: this.info.settingItem,
        key: 'settingTime',
        group: [
          {
            key: 'monthOption',
            col: '4',
            visible: this.info.settingId == 5,
            select: {
              options: [
                { value: '本月', key: 1 },
                { value: '次月', key: 2 }
              ]
            },
            change: () => {
              this.info.settingTime = ''
            }
          },
          {
            key: 'settingTime',
            placeholder: '请选择开始日期',
            date: {
              type: 'datetime',
              format: 'dd HH:mm:ss'
            }
          }
        ],
        rules: [
          ruleOpt.required(`请选择${this.info.settingItem}`),
          ruleOpt.check(`请选择月份`, (value) => {
            let flag = this.info.settingId == 5 ? (this.info.monthOption ? false : true) : false
            return flag
          })
        ]
      }
    ]
  }
}

export default ConfigOpt
